home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __SCENECAMERA_H_
- #define __SCENECAMERA_H_
- /*
- Peon - Win32 Games Programming Library
- Copyright (C) 2002-2005 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- peon AT wazooinc DOT com
- */
-
-
- #include "ISceneObject.h"
- #include "Vector3.h"
- #include "Plane.h"
-
- namespace peon
- {
- /**
- * This object acts as a wrapper around modifying the view matrix of the
- * scene (aka the view transformation stage of the pipeline).
- */
- class PEONMAIN_API SceneCamera : public ISceneObject
- {
-
- protected:
-
- /** the "Up" vector */
- Vector3 m_vecUp;
-
- /** the "LookAT" vector */
- Vector3 m_vecLookAt;
-
- /** our six view frustum planes */
- Plane m_oFrustumPlanes[6];
-
-
- public:
- /**
- * Constructor
- */
- SceneCamera();
-
- /**
- * Destructor
- */
- ~SceneCamera();
-
- /**
- * This method is responsible for capturing our current view
- * frustum matrix and dumping the data into 6 planes that
- * we can query
- */
- void generateViewFrustum();
-
- /**
- * This method is responsible for testing if a sphere has
- * hit a view frustum boundary.
- * @param x - x position of the sphere
- * @param y - y position of the sphere
- * @param z - z position of the sphere
- * @param float - radius of the sphere
- * @return bool - true if the sphere is inside the frustum
- */
- bool isSphereInFrustum( float x, float y, float z, float fRadius );
-
- /**
- * This method is responsible for setting the perspective
- * matrix for our camera
- * @param fAspect - the aspect ratio of the view
- * @param z_min - the minimum z-plane
- * @param z_max - the maximum z-plane
- */
- void setPerspectiveProj( float fAspect, float z_min, float z_max );
-
- /**
- * This method sets our camera viewpoint
- * @param vecEye - Vector3 of the eye point
- * @param vecLookAt - Vector3 coordinates of where we're lookin
- * @param vecLookUp - Vector3 coordinates of the up direction
- */
- void setViewMatrix( Vector3& vecEye, Vector3& vecLookAt, Vector3& vecUp);
-
- //this rotates the view around a specified axis.
- void rotateView(float X, float Y, float Z);
-
-
- virtual void updateView();
-
- /**
- * This method can be used to update the view matrix based
- * on the mouse's motion (if need be)
- * @param pEvent - the SDL_Event structure containing the mouse events
- */
- virtual void onMouseEvent( SDL_Event* pEvent );
-
- };
- }
-
- #endif
-